﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Helper.Core.Entity;
using System.Collections;
using System.Web.Helpers;

namespace Helper.Controllers
{
    public partial class UserController : BaseController
    {        
        [HttpGet]
        [ActionName("GetAll")]
        public JsonResult GetAll()
        {
            JsonResult result = new JsonResult();
            result.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            IEnumerable dataReturn = _UserRepository.GetAll().Select(obj => new { 
                Id = obj.Id, 
                Name = obj.Name,
                BusinessName = obj.ParentBusiness.Name,
                SectorName = obj.Sector.Name
            }).ToList();
            result.Data = dataReturn;
            return result;
        }

        [HttpPost]
        [ActionName("AuthUser")]
        public JsonResult AuthUser(DynamicJsonObject document)
        {
            return Json(new { Result = true });
        }
    }
}
